package hn.cch.feature.reflect;

import hn.cch.feature.reflect.entity.GenericInterface;
import hn.cch.feature.reflect.entity.GenericInterfaceImpl;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;

/**
 * 桥接方法
 */
public class BridgeMethodTest {

    @Test
    public void test() throws Exception {

        GenericInterface<String> i = new GenericInterfaceImpl();// 多态
        System.out.println(i.method("start"));
        Class<? extends GenericInterface> clazz = i.getClass();
        Method method = clazz.getMethod("method", Object.class);
        System.out.println(method.isBridge()); // true
        System.out.println(method.invoke(i, "hello"));
        // System.out.println(i.method(new Object())); // ClassCastException

    }


}


